package com.lt.experiment05.mission01;

import java.util.List;

/**
 * @author LT
 * @version 1.0
 * @PackageName com.lt.experiment05.mission01
 * @ClassName Concretelterator
 * @Description to do
 * @date 2021/11/16 10:43
 */
public class Menulterator implements Abstractlterator{
    private List<Object> menus;
    private int cursor;

    public Menulterator(MenuList menuList) {
        this.menus = menuList.getObjects();
        cursor=0;
    }

    @Override
    public void first() {
        cursor=0;
    }

    @Override
    public void next() {
        if (cursor < menus.size()){
            cursor++;
        }
    }

    @Override
    public boolean hasNext() {
        int i=cursor;
        if (i+1<=menus.size()){
            return true;
        }
        return false;
    }

    @Override
    public Object currentItem() {
        return menus.get(cursor);
    }
}
